﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;

namespace ConsoleApplicationTeste
{
    public class Edge
    {
        public Vertex destination; // The destination Vertex of the Edge
        public Edge(Vertex d)
        {
            destination = d;
        }
    }

    public class Vertex
    {
        public String name;
        public LinkedList<Edge> outEdges; // The out-bound Edges of this Vertex
        public int inDegree; // A convenient *scratch variable* for our algorithm to use

        public Vertex(String nm)
        {
            name = nm;
            outEdges = new LinkedList<Edge>();
            inDegree = 0;
        }
    }


    public class Graph
    {
        List<Vertex> vertexCollect;

        public Graph()
        {
            vertexCollect = new List<Vertex>();
        }

        public List<Vertex> vertices()
        {
            return vertexCollect; // Return all Vertices in the Graph
        }

        public void addVertex(Vertex v)
        {
            vertexCollect.Add(v);
        }

        public void addEdge(String From, String To)
        {
            Edge e = null;
            foreach (Vertex v in vertexCollect)
            {
                if (v.name.Equals(From))
                {
                    foreach (Vertex vDest in vertexCollect)
                    {
                        if (vDest.name.Equals(To))
                        {
                            e = new Edge(vDest);
                        }
                    }
                   
                    v.outEdges.AddLast(e);
                }
            }
        }

        public long size()
        {
            // Return the number of Vertices in the Graph
            return vertexCollect.Count;
        }
    }

}
